package com.impinj.program;

import com.impinj.octane.ImpinjReader;
import com.impinj.octane.ReadResultStatus;
import com.impinj.octane.TagOpReport;
import com.impinj.octane.TagOpResult;
import com.impinj.octane.TagReadOpResult;

public class MyTagOpCompleteListernerImplementation {
	// 重写显示程序，数据库写入模块也在其中
	public static TagReadOpResult myOnTagOpComplete(ImpinjReader reader, TagOpReport results) {
		for (TagOpResult t : results.getResults()) {
			// 不输出 EPC 名称
        	// System.out.print("    EPC: " + t.getTag().getEpc().toString());
            if (t instanceof TagReadOpResult) {
                // 处理读操作的结果
                TagReadOpResult tr = (TagReadOpResult) t;
                if (tr.getResult().toString().equals("Success") && !tr.getData().toHexString().substring(0, 4).equals("0000")) {
                	System.out.print(" - READ: id: " + tr.getOpId());
                	System.out.print(", sequence: " + tr.getSequenceId());
                	System.out.print(", result: " + tr.getResult().toString());
                	if (tr.getResult() == ReadResultStatus.Success) {
                		System.out.println(", data: " + tr.getData().toHexWordString());
                	}
                	return tr;
				}
            }
		}
		return null;
	}
}
